package com.zwp.common

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContract
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.lifecycleScope
import androidx.paging.PagingData
import androidx.paging.map
import androidx.recyclerview.widget.DiffUtil
import com.google.android.material.shape.*
import com.zwp.base.base.BaseActivity
import com.zwp.base.paging.BindingRecyclerViewAdapter
import com.zwp.common.databinding.ActivityMainBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import me.tatarka.bindingcollectionadapter2.ItemBinding

@AndroidEntryPoint
class MainActivity : BaseActivity<MainViewModel,ActivityMainBinding>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }


    override fun getLayoutResId(): Int = R.layout.activity_main

    override fun initData() {

    }

    override fun initObservale() {
        lifecycleScope.launch {
            viewModel.loadData().collect {
                viewModel.submitData(it)
            }
        }
        viewModel.uc.onReloadPressedEvent.observe(this) {
            viewModel.adapter.refresh()
        }
    }

}